package cn.wolfcode.rbac.query;

import java.util.Collections;
import java.util.List;

public class PageResult{
    private Integer currentPage;
    private Integer pageSize;
    private List<?> list;
    private Integer totalCount;
    private Integer prevPage;
    private Integer nextPage;
    private Integer totalPage;

    public String toString()
    {
        return "PageResult(currentPage=" + getCurrentPage() + ", pageSize=" + getPageSize() + ", list=" + getList() + ", totalCount=" + getTotalCount() + ", prevPage=" + getPrevPage() + ", nextPage=" + getNextPage() + ", totalPage=" + getTotalPage() + ")";
    }

    public Integer getCurrentPage()
    {
        return this.currentPage;
    }

    public Integer getPageSize()
    {
        return this.pageSize;
    }

    public List<?> getList()
    {
        return this.list;
    }

    public Integer getTotalCount()
    {
        return this.totalCount;
    }

    public Integer getPrevPage()
    {
        return this.prevPage;
    }

    public Integer getNextPage()
    {
        return this.nextPage;
    }

    public Integer getTotalPage()
    {
        return this.totalPage;
    }

    public PageResult(Integer pageSize)
    {
        this(Integer.valueOf(1), Integer.valueOf(0), Collections.EMPTY_LIST, pageSize);
    }

    public PageResult(Integer currentPage, Integer totalCount, List<?> list, Integer pageSize)
    {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.list = list;
        this.totalCount = totalCount;

        this.totalPage = Integer.valueOf(totalCount.intValue() % pageSize.intValue() == 0 ? totalCount.intValue() / pageSize.intValue() : totalCount.intValue() / pageSize.intValue() + 1);
        this.prevPage = Integer.valueOf(currentPage.intValue() > 1 ? currentPage.intValue() - 1 : 1);
        this.nextPage = Integer.valueOf(currentPage.intValue() < this.totalPage.intValue() ? currentPage.intValue() + 1 : this.totalPage.intValue());
    }
}
